<?php

class DatabaseController extends Project_Controller{
    
	public function sqlAction() {
		$this->initExample();
		
    	echo '<h1>class Frogg_Db_Sql</h1>';
        $sql = new Frogg_Db_Sql('SELECT * FROM `example`');
    	echo '<ul>';
        echo '<li><b> public __construct(\'SELECT * FROM `example`\')</b></li>';
        echo '<li><b> public fetch()</b>';
		while($row = $sql->fetch()){
	        var_dump($row);
		}        
        echo '</li>';
        echo '<li><b> public rows():</b> '.$sql->rows().'</li>';
        echo '</ul>';
        die;
    }
    
	/**
	 * Creates the database table used in sqlAction() 
	 */
    public function initExample(){
    	echo "
    	<h1>Database Table</h1>
    	<table border='2'>
    		<tr>
    			<td>ID</td>
    			<td>VALUE</td>
    		</tr>
    		<tr>
    			<td>1</td>
    			<td>Hello World</td>
    		</tr>
    		<tr>
    			<td>2</td>
    			<td>Hola Mundo!</td>
    		</tr>
    	</table>
    	";
		$model = new Application_Model_Example();
		Frogg_DAO::createDB($model);
		$model->value = 'Hello World';
		$model->save();
		$model->value = 'Hola Mundo!';
		$model->save();
    }
}